package com.webex.ta.hydra.gui.action;

import com.webex.ta.hydra.gui.GuiPackage;
import com.webex.ta.hydra.gui.macro.MacroEditor;
import com.webex.ta.hydra.gui.macro.MacroEditorContext;
import com.webex.ta.hydra.gui.table.HydraTable;
import com.webex.ta.hydra.gui.util.ComponentUtil;

import java.awt.event.ActionEvent;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by Cisco WebEx.
 * User: vegaz
 * Date: 2010-9-13
 * Time: 15:36:38
 */
public class MacroEditAction implements ActionHandler {
    private static Set<String> commands = new HashSet<String>();

    static {
        commands.add(ActionNames.EDIT_MACRO);
    }

    public Set<String> getActionNames() {
        return commands;
    }

    public void doAction(ActionEvent e) {
        HydraTable mainTable = GuiPackage.getInstance().getHydraTable();
        MacroEditor editor = new MacroEditor(GuiPackage.getInstance().getIdeFrame(), true);
        GuiPackage.getInstance().setHydraTable(editor.getTable());
        MacroEditorContext.getInstance().setEditor(editor);
        editor.setTitle("Macro Editor");
        ComponentUtil.centerComponentInWindow(editor);
        editor.setVisible(true);
        MacroEditorContext.getInstance().setEditor(null);
        GuiPackage.getInstance().setHydraTable(mainTable);

    }
}
